﻿/*
   Advanced Flash Engine in ActionScript 3.
   Copyright (C) 2009  Dean Gardiner, Taylor Lodge

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.winmastergames.lolgame.weapons {
	import flash.display.*;
	import flash.events.*;
	import flash.display.Stage;
	import com.winmastergames.lolgame.mapDefault;

	public class base extends MovieClip {
		public var myStage:mapDefault; //Set's the stage to mapDefault
		public var myMC:MovieClip; //?
		public var ammoRemaining:Number;
		public var maxClip:Number;
		public var fireRate:Number;
		public var damage:Number;
		public var defaultDamage:Number;
		public var reloadTime:Number;
		public var semiAuto:Boolean;
		public var type:String;
		public var ammoType:String;

		//Set's the value of the weapon name so we can use it to display the "Pretty" names to the user instead of the engine names
		public function base(writeStage:mapDefault, writeX:Number, writeY:Number, ammo:Number) //Set's ref tp mapDefault, writeX and writeY are the spawn x,y
		{
			ammoRemaining = ammo;
			writeStage.objects.addChild(this); //Add's it to the objects movieclip in the stage
			myStage = writeStage; //Set's mystage to writestage dunno why.
			x = writeX; //Set's it's x to the writePosition set in the function
			y = writeY; //Set's it's y to the writePosition set in the function
			myMC = MovieClip(this.parent.getChildByName(this.name)); //?
			addEventListener(Event.ENTER_FRAME, loop); //For somereason a loop is needed or we get errors
		}

		public function loop(e:Event){

		}

		//onPickup is called when you pick a gun up in player.as 
		public function onPickup(id:Number){
			//Removes the weapon from the stage
			myStage.objects.removeChild(myMC);
		}

		public function onDrop(){
			//Unused so far
		}

		//This function is used for checking how much ammo the current instance of this weapon has
		public function getAmmo(){
			return (ammoRemaining);
		}

		//This function is used for setting how much ammo the current instance of this weapon has
		public function setAmmo(ammo:Number){
			ammoRemaining = ammo;
		}
	}
}